<?php
require_once( 'classes/class.Spectre.php' );
$oTemplate = new Spectre();
$file = isset( $_GET['f'] ) ? $_GET['f'] : '' ;
list( $content , $mtime ) = $oTemplate->loadCacheFile( $file );

ob_start( 'ob_gzhandler' );
if( substr( $file , 0 , 3 ) == 'css' ) {
	header( 'Content-Type: text/css' );
}
else {
	header( 'Content-Type: text/javascript' );
}
$headers = apache_request_headers();
if (
	$content !== false &&
	isset( $headers['If-Modified-Since'] ) && 
	( strtotime( $headers['If-Modified-Since'] ) > $mtime )
) {
	header( 'Last-Modified: '.gmdate('D, d M Y H:i:s', $mtime ).' GMT', true, 304 );
	header( "Expires: ".gmdate('D, d M Y H:i:s' , $mtime+365*24*60*60 )." GMT"  );
	exit();
}
else {
	header( 'Last-Modified: '.gmdate('D, d M Y H:i:s' ) . ' GMT', true, 200);
	header( "Expires: ".gmdate('D, d M Y H:i:s' , time()+365*24*60*60 )." GMT"  );
}
echo $content;
